﻿using System;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Windows.Forms;
using SerbinAV.MobileSales.Sales.Common;
using SerbinAV.MobileSales.Sales.Presenters;

namespace SerbinAV.MobileSales.Sales.Views
{
    public class InitializerView : Form, IInitializerView
    {
        private ProgressBar _progressBar;
        private static Bitmap backgroundBmp = null;
        private string _status = string.Empty;

        public InitializerView()
        {
            _progressBar = new ProgressBar();
            _progressBar.Dock = DockStyle.Bottom;
            _progressBar.Height = 20;
            _progressBar.Maximum = 3;
            _progressBar.Value = 0;
            this.Controls.Add(this._progressBar);
            base.Show();
            this.Invalidate(new Rectangle(0, 0, this.Width, this.Height));
            Application.DoEvents();
           // new InitializePresenter(null, this).Go();
        }

        public new bool Show()
        {
            throw new NotImplementedException();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            Font font = new Font("Arial", 10, FontStyle.Bold);
            if (backgroundBmp == null)
                backgroundBmp = (Bitmap)new ResourceManager("SerbinAV.MobileSales.Sales.Views.InitializerView", Assembly.GetExecutingAssembly()).GetObject("SplashBack");
            e.Graphics.DrawImage(backgroundBmp, 0, 0);
            e.Graphics.DrawString(_status, font, new SolidBrush(Color.Yellow), 0, this.Height - _progressBar.Height - 20);
        }


        public void PaintProcess()
        {
            this.Invalidate(new Rectangle(0, 0, this.Width, this.Height));
            _progressBar.Value++;
            Application.DoEvents();
        }


        protected override void Dispose(bool disposing)
        {
            _progressBar.Dispose();
            base.Dispose(disposing);
        }

        public string Status
        {
            get
            {
                return _status;
            }
            set
            {
                _status = value;
                PaintProcess();

            }
        }

        #region IView Members



        #endregion
    }
}
